using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace GraphMyCode.Controls
{
	public class BooleanToVisibilityConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			bool isVisible = System.Convert.ToBoolean(value);

			return isVisible ? Visibility.Visible : Visibility.Collapsed;
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			Visibility visibility = (Visibility)value;

			switch (visibility)
			{
				case Visibility.Visible:
					return true;
				case Visibility.Collapsed:
					return false;
				default:
					throw new ArgumentOutOfRangeException();
			}
		}
	}
}